<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            background-color: black;
        }
       
    </style>
    
</head>
<body>
    <div class="main">
        <img id="img" src="img/player_left.gif">
    </div>
	<script src="./js/jquery-3.1.1.min.js"></script>
    <script>
        var timer = null;
		//添加双击事件
        $("#img").dblclick(function(){
            clearTimeout(timer);
            $(this).attr({src:"img/player2.gif"});
        })
        //添加点击事件
        $(".main").click((e)=>{
            clearTimeout(timer);
            timer = setTimeout(()=>{
                let $img = $("#img");
                let imgX = parseInt($img.offset().left);

                if($img.attr("src")!="img/player2.gif")
                    if(imgX > e.pageX) $img.attr("src","img/player_left.gif")
                    else $img.attr("src","img/player_right.gif")
				//操作动画
                $img.animate({
                    marginLeft:e.pageX,
                    marginTop:e.pageY
                },5000);
            },250);
        });
        $($(document).on("contextmenu",() => {return false;}));
    </script>
</body>
</html>




   